package com.horrorshallots.horrorshallotsblog2.deepseek.mapper;

import com.horrorshallots.horrorshallotsblog2.deepseek.pojo.DeepSeekRequest.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DialogueMapper {
    @Insert("INSERT INTO conversation_history(session_id, role, content) VALUES(#{sessionId}, #{message.role}, #{message.content})")
    void saveMessage(@Param("sessionId") String sessionId, @Param("message") Message message);

    @Select("SELECT role, content FROM conversation_history WHERE session_id = #{sessionId} ORDER BY create_time ASC")
    List<Message> getMessagesBySessionId(String sessionId);

    @Delete("DELETE FROM conversation_history WHERE session_id = #{sessionId}")
    int deleteMessagesBySessionId(String sessionId);
}